package com.lmx.repoDomain.model;

import io.katharsis.response.MetaInformation;

/**
 * 分页信息
 * Created by qin on 2016/6/13.
 */
public class PageInfo implements MetaInformation{
    private static ThreadLocal threadLocal = new ThreadLocal();//安全线程
    public String name = "page information";
    public Integer totalCount;// 总条数
    public Integer size = 10; // 分页条数 默认：10
    public Integer totalPage;// 总页数
    public Integer currPage = 1;// 当前页 默认：第一页
    public Integer startNum = 1;// 当前页开始条数
    public Integer endNum;// 当前页结束条数

    /**
     * 安全线程获取PageInfo实例  防止线程冲突（不同请求分页信息混乱）
     * @return PageInfo
     */
    public static PageInfo getInstance() {
        if (threadLocal.get()==null) {
            threadLocal.set(new PageInfo());
        }
        return  (PageInfo) threadLocal.get();
    }

    /**
     * 清空当前线程变量
     */
    public static void clear(){
        if (threadLocal.get() != null) {
            threadLocal.remove();
        }
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public Integer getCurrPage() {
        return currPage;
    }

    public void setCurrPage(Integer currPage) {
        this.currPage = currPage;
    }

    public Integer getStartNum() {
        return startNum;
    }

    public void setStartNum(Integer startNum) {
        this.startNum = startNum;
    }

    public Integer getEndNum() {
        return endNum;
    }

    public void setEndNum(Integer endNum) {
        this.endNum = endNum;
    }
}
